from django.db import models
from django.contrib.auth.models import AbstractUser, User


class UserProfile(AbstractUser):
    phone = models.CharField("手机号", max_length=11)

    class Meta:
        db_table = "user_profile"


# 基础类
class BaseModel(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


# 第三方账号用户Model

class OpenUser(BaseModel):
    uid = models.CharField(max_length=20)
    type = models.CharField(max_length=10)
    user = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, null=True)

    class Meta:
        db_table = "open_user"


# 浏览记录表

class Goods(BaseModel):
    pass


class History(BaseModel):
    user = models.ForeignKey(UserProfile, on_delete=models.SET_NULL, null=True)
    goods = models.ForeignKey(Goods, on_delete=models.SET_NULL, null=True)


